package com.bytedance.article.b.a;

import android.util.Log;

import com.bytedance.article.b.b.DependProvider;
import com.bytedance.article.b.JsonTransformer;
import com.bytedance.common.utility.Logger;

public final class GsonDependManager implements JsonTransformer {
    public JsonTransformer jsonTransformer;
    private static DependProvider<GsonDependManager> gsonDependManagerDependProvider = new GsonDependManagerDependProvider();

    public GsonDependManager() {

    }

    public static GsonDependManager getInstance() {
        return GsonDependManager.gsonDependManagerDependProvider.getInstance();
    }

    public final <T> T fromJson(String json, Class<T> clazz) {
        if (this.jsonTransformer != null) {
            try {
                return (T) this.jsonTransformer.fromJson(json, clazz);
            } catch (Exception exception) {
                Log.d("GsonDependManager", "fromJson exception: " + exception);
                if (!Logger.debug()) {
                    return null;
                }
                throw new IllegalArgumentException(exception);
            }
        }
        return null;
    }
}

